package com.zego.wawaji.ui.dialog.share;

import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.zego.wawaji.R;
import com.zego.wawaji.base.module.ModuleMgr;
import com.zego.wawaji.ui.UIShow;
import com.zego.wawaji.ui.dialog.popup.BottomPopup;

/**
 * 成功被邀请弹框
 * Created by Su on 2017/12/16.
 */
public class InviteDialog extends BottomPopup {
    private int awardNum;   // 兑换娃娃币数量

    public InviteDialog(FragmentActivity activity) {
        super(activity);
        setCancelableOutTouch(false);
    }

    @Override
    protected View makeContentView() {
        View inflate = LayoutInflater.from(activity).inflate(R.layout.invite_suc_dialog, null);

        TextView tv_award_num = (TextView) inflate.findViewById(R.id.tv_award_num);
        tv_award_num.setText("获得" + awardNum + "个娃娃币");
        ModuleMgr.getCenterMgr().reqMyInfo(null);  // 更新个人资料

        inflate.findViewById(R.id.btn_invite).setOnClickListener(v -> {
            dismiss();
            UIShow.showInviteAct(getActivity());
        });

        inflate.findViewById(R.id.play_close).setOnClickListener(v -> {
            dismiss();
            ModuleMgr.getWawaMgr().reqNewVersion(false, null);
        });

        return inflate;
    }

    /**
     * 设置娃娃币数量
     */
    public void setAwardNum(int awardNum) {
        this.awardNum = awardNum;
    }
}
